/**
 * @BitmapNumsManager.as
 * 
 * @author sodaChen mail:sujun10#21cn.com
 * @version 1.0
 * <br>Copyright (C), 2010 asFrame.com
 * <br>This program is protected by copyright laws.
 * <br>Program Name:挂机冒险
 * <br>Date:2014-6-18
 */
package com.asframe.display.nums
{
	import com.asframe.collections.maps.HashMap;
	import com.asframe.pool.FactoryObjectPool;
	import com.asframe.pool.ObjectPool;
	
	import flash.display.BitmapData;

	/**
	 *
	 * @author sodaChen
	 * Date:2014-6-18
	 */
	public class BitmapNumsMgr
	{
		private static var numsFactoryMap:HashMap = new HashMap();
		
		public static function registerFactory(key:String,factory:BitmapNumsFactory,maxIdle:int = 10):void
		{
			var pool:FactoryObjectPool = new FactoryObjectPool(factory,maxIdle);
			numsFactoryMap.put(key,pool);
		}
		public static function register(key:String,maxIdle:int,bitmapDatas:Vector.<BitmapData>,align:int = 0,maxLen:int = 10,isShowZero:Boolean = false):void
		{
			var factory:BitmapNumsFactory = new BitmapNumsFactory(bitmapDatas,align,maxLen,isShowZero);
			registerFactory(key,factory,maxIdle);
		}
		public static function unRegister(key:String,isDestory:Boolean = true):void
		{
			var pool:ObjectPool = numsFactoryMap.remove(key);
			if(pool != null)
			{
				pool.destroy(isDestory);
			}
		}
	}
}